<template>
	<div class="s_journal">
		<ul v-loading="loading">
			<template   v-for="(item ,index) of journalList">
				<li class="i_log clear" :key="index">
<!-- 					<a :href="BASE_URL + item.journal_url">
						
					</a> -->
					<router-link :to="{path:'/space/journal-detail',query:{id: item.id}}">{{item.name}}</router-link>
					<i>{{item.create_time.substr(0,11)}}</i>
				</li>
			</template>
			
		</ul>
		<el-pagination v-if="parseInt(total_number) > size"
	      @current-change="changePage"
	      :current-page="page"
	      :page-size="size"
	      layout="prev, pager, next"
	      :total="total_number">
	    </el-pagination>
	    <div class="dependent" v-if="placeholder">
	    	<i class="ipng image_state01"></i>
	    	<p>
	    		还没发现任何相关的内容哦~
	    	</p>
	    </div>
	</div>
</template>

<script>
	export default{
		name: '',
		data() {
			return {
				listJournalParam:{
					type:2,
					create_id: this.$route.query.id,
					size:1,
					page:1,
					data_type:2,
					authority:1,
					orderby:'id',
					orderby_desc:1,
				},

				type:2,
				create_id: this.$route.query.id,
				size:12,
				page:1,
				data_type:2,
				orderby:'id',
				orderby_desc:1,

				total_number:0,
				journalList:[],
				placeholder: false,
				loading: true
			}
		},
		created(){
	       this.getJournalList();
		},
		methods: {
			//分页改变
            changePage(val) {
            	this.page = val;
    			this.getJournalList();
            },

            getJournalList(){
            	let success = (data=>{
            		this.journalList = data.data.data;
            		this.total_number = data.data.data_sum;

            		this.loading = false
            		this.journalList.length === 0
            		? this.placeholder = true
            		: this.placeholder = false
            	})

            	if (this.$g.user_id == this.create_id) {
            		this.$ajax.get('api/resource/journal',{
            			params: {
            				type:2,
            				create_id: this.$route.query.id,
            				size: this.size,
            				page:this.page,
            				data_type:2,
            				orderby:'id',
            				orderby_desc:1,
            				stutas: '1,2,3',
            				authority: '-1'
            			},
            			func:{success:success}
            		})
            	}else{
            		this.$ajax.get('api/resource/journal',{
            			params: {
            				type:2,
            				create_id: this.$route.query.id,
            				size: this.size,
            				page:this.page,
            				data_type:2,
            				authority:1,
            				orderby:'id',
            				orderby_desc:1,
            				stutas: '1',
            				authority:1
            			},
            			func:{success:success}
            		})
            	}
            	//执行请求，并将回调方法变成config成员以便鉴权过期可以执行
            	// this.$ajax.get('api/resource/journal',{params: this.listJournalParam,func:{success:success}})
            },
           
		}
	}
</script>